import React, {Component} from "react";
import PropTypes from "prop-types";
import {Text, View} from "react-native";
import {List, Modal, SwipeAction} from "antd-mobile";
import moment from "moment";
import "moment/locale/zh-cn";

const Item = List.Item
const Brief = Item.Brief
const zhNow = moment().locale('zh-cn').utcOffset(8)

const scancodeImg = require('../../img/Normal/scancode.png')
const handenterImg = require('../../img/Normal/handenter.png')
const cameraImg = require('../../img/Normal/camera.png')
const batchImg = require('../../img/Normal/batch.png')

const alert = Modal.alert



export default class BatchScanCode extends Component {
  static propTypes = {
    code: PropTypes.string,
    delFunc: PropTypes.func
  }
  render() {
    const { code } = this.props
    const firstCode = code.substring(0, code.indexOf('@'))
    const count = code.substring(code.indexOf('@') + 1)
    return (
      <SwipeAction
        autoClose
        right={[
          {
            text: '取消',
            onPress: () => console.log('cancel'),
            style: { backgroundColor: '#ddd', color: 'white' },
          },
          {
            text: '删除',
            onPress: () => { this.props.delFunc(this.props.code) },
            style: { backgroundColor: '#F4333C', color: 'white' },
          },
        ]}
      >
        <Item>
          <View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
            <Text style={{fontWeight: 'bold', color: '#333333'}}>首位号码:{firstCode}</Text>
          </View>
          <View style={{height: 5}}></View>
          <View><Text>数量:{count}</Text></View>
        </Item>
      </SwipeAction>
    )
  }
}
